package rank
{
	import flash.display.Bitmap;
	import flash.display.Sprite;
	
	import utils.DisplayTool;
	
	public class RankNumber extends Sprite
	{
		private var num:int;
		
		public function RankNumber()
		{
			this.mouseChildren = false;
			this.mouseEnabled = false;
		}
		
		public function set value(v:int):void
		{
			clear();
			num = v;
			var arr:Array = getNumbers(v);
			for (var i:int=0; i<arr.length; i++)
			{
				var bitmap:Bitmap = new Bitmap(RankTool.num[int(arr[i])]);
				bitmap.x = bitmap.width * i;
				addChild(bitmap);
			}
		}
		
		public function get value():int
		{
			return num;
		}
		
		private function getNumbers(num:int):Array
		{
			var n:String = num.toString();
			var array:Array = n.split("");
			return array;
		}
		
		public function clear():void
		{
			DisplayTool.removeAllChild(this);
		}
	}
}